package com.chenlehao.config;

import com.chenlehao.interceptor.interceptorLogin;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;
import java.util.List;

@Configuration
public class interceptorConfig implements WebMvcConfigurer {
    @Autowired
    private interceptorLogin interceptorLogin;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        String[] apis = {"/login", "/getAll"};
        List<String> api = new ArrayList<>(List.of(apis));
        api.add("/ww");
        System.out.println(api);
        // 配置该拦截器的拦截路径和排除拦截路径
        registry.addInterceptor(interceptorLogin).excludePathPatterns(api);
    }
}
